﻿# 规则名称
$ruleName = [char]0x0052 + [char]0x0050 + [char]0x0047 + [char]0x670D + [char]0x6D88 + [char]0x5931 + [char]0x5427

# 尝试删除入站规则
try {
    $existingInboundRule = Get-NetFirewallRule -DisplayName ($ruleName + "_in")
    if ($existingInboundRule -ne $null) {
        Remove-NetFirewallRule -DisplayName ($ruleName + "_in")
        Write-Host "已删除入站规则: $($ruleName + "_in")"
    } else {
        Write-Host "未找到入站规则: $($ruleName + "_in")"
    }
} catch {
    Write-Host "无法删除入站规则。错误信息: $_"
}

# 尝试删除出站规则
try {
    $existingOutboundRule = Get-NetFirewallRule -DisplayName ($ruleName + "_Out")
    if ($existingOutboundRule -ne $null) {
        Remove-NetFirewallRule -DisplayName ($ruleName + "_Out")
        Write-Host "已删除出站规则: $($ruleName + "_Out")"
    } else {
        Write-Host "未找到出站规则: $($ruleName + "_Out")"
    }
} catch {
    Write-Host "无法删除出站规则。错误信息: $_"
}
